package com.sangeng.controller;

import com.sangeng.constant.enums.AppHttpCodeEnum;
import com.sangeng.domain.core.ResponseResult;
import com.sangeng.domain.dto.RoleInsertDto;
import com.sangeng.domain.dto.RoleListDto;
import com.sangeng.domain.dto.RoleStatusDto;
import com.sangeng.domain.dto.RoleUpdateDto;
import com.sangeng.domain.entity.Role;
import com.sangeng.service.MenuService;
import com.sangeng.service.RoleService;
import com.sangeng.utils.BeanUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/role")
@RequiredArgsConstructor
public class RoleController {

    private final RoleService roleService;
    @GetMapping("/list")
    public ResponseResult list(RoleListDto roleListDto) {
        return roleService.listAllRoles(roleListDto);
    }

    @PutMapping("/changeStatus")
    public ResponseResult changeStatus(@RequestBody RoleStatusDto roleStatusDto) {
        return roleService.changeStatus(roleStatusDto);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody RoleInsertDto role) {
        return roleService.insertRole(role);
    }

    @GetMapping("/{id}")
    public ResponseResult getById(@PathVariable Long id) {
        return roleService.getRoleById(id);
    }

    @PutMapping
    public ResponseResult update(@RequestBody RoleUpdateDto roleUpdateDto) {
        return roleService.updateRole(roleUpdateDto);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Long id) {
        return roleService.removeRoleById(id);
    }

    @GetMapping("/listAllRole")
    public ResponseResult listAllRole() {
        return roleService.listAllRole();
    }
}
